# -*- coding: UTF-8 -*-
# Field 标签
NAME,AGE,PAY = range(3)  # 0,1,2
bob = ['Bob Smith', 42, 10000]
print(bob[NAME])
print(PAY)
print(bob[PAY])
# 结果：
# Bob Smith
# 2
# 10000

bob = [['name','Bob Smith'],['age',42],['pay',10000]]
sue = [['name','Sue Jones'],['age',45],['pay',20000]]
people = [bob, sue]

for person in people:
    for(name, value) in person:
        if name == 'name': print(value)  # 寻找特定的字段
        if name == 'age': print(value)
# 结果：
# Bob Smith
# 42
# Sue Jones
# 45

def field(record, label):
    for(fname,fvalue) in record:
        if fname == label:
            return fvalue
print(field(bob, 'name'))
# 结果：Bob Smith
print(field(bob, 'pay'))
# 结果：10000

for rec in people:
    print(field(rec,'age'))
# 结果：
# 42
# 45